package com.ncs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ncs.pojo.Reservation;
import com.ncs.pojo.Table;
import com.ncs.service.ReservationService;
import com.ncs.mapper.ReservationMapper;
import com.ncs.service.TableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
* @author Lenovo
* @description 针对表【reservation】的数据库操作Service实现
* @createDate 2022-09-05 14:33:14
*/
@Service
public class ReservationServiceImpl extends ServiceImpl<ReservationMapper, Reservation>
    implements ReservationService{
    @Autowired
    TableService tableService;


    /**
     * 添加预定信息，同时需要添加信息和更改餐桌表状态
     *
     */
    @Transactional//多表操作，加入事务管理控制
    public void saveWithTable(Reservation reservation) {
        int tableId  = reservation.getTableId();
        //存储，先存预定表中的数据
        this.save(reservation);
        //再更新餐桌表的状态
        tableService.updateState(tableId);
    }
}




